package com.lambert.gingko.autoconfigure;

import com.lambert.gingko.watermark.config.WatermarkProperties;
import com.lambert.gingko.watermark.factory.WatermarkStrategyFactory;
import com.lambert.gingko.watermark.service.WatermarkService;
import com.lambert.gingko.watermark.strategy.WatermarkProcessor;
import com.lambert.gingko.watermark.strategy.impl.*;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

import java.util.List;

/**
 * 水印自动配置类
 * 1. 自动配置水印服务
 * 2. 自动配置水印策略工厂
 *
 * @author liubaolin
 * @since 2025/9/8 10:05
 */
@AutoConfiguration
@EnableConfigurationProperties(WatermarkProperties.class)
public class WatermarkAutoConfiguration {

    @ConditionalOnClass(Workbook.class)
    @Bean
    public ExcelWatermarkProcessor excelWatermarkProcessor() {
        return new ExcelWatermarkProcessor();
    }

    @ConditionalOnClass(XWPFDocument.class)
    @Bean
    public WordWatermarkProcessor wordWatermarkProcessor() {
        return new WordWatermarkProcessor();
    }

    @Bean
    public ImageWatermarkProcessor imageWatermarkProcessor() {
        return new ImageWatermarkProcessor();
    }

    @Bean
    @ConditionalOnClass(PDDocument.class)
    public PdfWatermarkProcessor pdfWatermarkProcessor() {
        return new PdfWatermarkProcessor();
    }

    @Bean
    @ConditionalOnClass(FFmpegFrameGrabber.class)
    public VideoWatermarkProcessor videoWatermarkProcessor() {
        return new VideoWatermarkProcessor();
    }

}
